package la.iok.hzsvn.lewin.movie.cloud.service;

import la.iok.hzsvn.lewin.movie.cloud.entity.OrgUnit;
import la.iok.hzsvn.lewin.movie.core.model.OrgUnitType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrgUnitUtils {
    @Autowired
    private OrgUnitService orgUnitService;

    public Long prepareShop(String name,Long userId){
        return prepareShop(name, userId, null);
    }

    public Long prepareShop(String name,Long userId, Integer hideCloudMovie) {
        OrgUnit orgUnit = new OrgUnit();
        orgUnit.setName(name);
        orgUnit.setType(OrgUnitType.SHOP.getCode());
        orgUnit.setCreateUserId(userId);
        orgUnit.setHideCloudMovie(hideCloudMovie);
        orgUnitService.insertSelective(orgUnit);
        return orgUnit.getId();
    }

    public Long prepareFranchisee(String name,Long userId){
        OrgUnit orgUnit = new OrgUnit();
        orgUnit.setName(name);
        orgUnit.setType(OrgUnitType.FRANCHISEE.getCode());
        orgUnit.setCreateUserId(userId);
        orgUnitService.insertSelective(orgUnit);
        return orgUnit.getId();
    }
}
